// ----------------------------------------------------------------------------
// main.cpp
// ----------------------------------------------------------------------------
#include <iostream>
#include <cstdlib>
#include <fw/base/core/macros.h>
#include <fw/base/core/assertion.h>
#include <fw/base/runtime/registration_object.h>
#include <fw/base/runtime/allocator.h>

#include <gtest/gtest.h>

#include <memory>

void CORE_UNIT_TEST();
void CONCURRENT_UNIT_TEST();
void MATH_UNIT_TEST();
void RUNTIME_UNIT_TEST();
void STL_UNIT_TEST();
void CONTAINER_UNIT_TEST();
void SERIALIZE_UNIT_TEST();

// for eastl test.
void* operator new[](size_t size, const char* pName, int flags,
					 unsigned debugFlags, const char* file, int line)
{
    return operator new[](size);
}
void* operator new[](size_t size, size_t alignment, size_t alignmentOffset,
					 const char* pName, int flags, unsigned debugFlags, const char* file, int line)
{
    // doesn't support alignment
    return operator new[](size);
}

void operator delete[](void* ptr, const char* pName, int flags,
					   unsigned debugFlags, const char* file, int line)
{
    operator delete[](ptr);
}
void operator delete[](void* ptr, size_t alignment, size_t alignmentOffset,
					   const char* pName, int flags, unsigned debugFlags, const char* file, int line)
{
    // doesn't support alignment
    operator delete[](ptr);
}

using namespace fw;
using namespace std;

void test()
{
    std::shared_ptr<int> p[8];
    
    p[0] = std::make_shared<int>(5963);
    
    int value = *(p[0]);

    printf("p[0] = %d / ref count = %ld\n", value, p[0].use_count());
    
}

int main (int argc, char* argv[])
{
#if defined(FW_ENABLE_UNIT_TEST)
	CORE_UNIT_TEST		();
	CONCURRENT_UNIT_TEST();
	MATH_UNIT_TEST      ();
	STL_UNIT_TEST		();
	CONTAINER_UNIT_TEST	();
	SERIALIZE_UNIT_TEST	();
	RUNTIME_UNIT_TEST	();
	
	testing::InitGoogleTest(&argc, argv);
	int result = RUN_ALL_TESTS();
    FW_UNUSED(result);
#endif
    test();
    
    return 0;
}

